<div class="modal-body no-p">
    <div class="row">
        <div class="col-xs-12">
            <section class="panel panel-primary no-b">
                <header class="panel-heading clearfix brtl brtr">
                    <div class="overflow-hidden">
                        <a href="javascript:;" class="h4 show no-m pt5">添加场地</a>
                    </div>
                </header>
                <div class="row mb10" style="text-align: center;padding-top: 10px;">
                
                	<label for="pcode1">省</label>
                   <select id="pcode1" name="pcode1" onchange="city(this.value);">
			        	<option value="">--请选择--</option>
			           	<% for(o in obj){ if("1"==o.parent_id ){%>
			            	<option value="${o.id};${o.ad_code}">${o.name}</option>
			            <%}}%>
			        </select>
			                
			        <label for="ccode1">市</label>
				    <select id="ccode1" name="ccode1" onchange="pp(this.value);">
			        	<option value="">--请选择--</option>
			        </select>
			                
			        <label for="ppcode1">区</label>
				    <select id="ppcode1" name="ppcode1">
			        	<option value="">--请选择--</option>
			        </select>
                </div>
            </section>

        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
    <button onclick="doIt()" id="ok" type="button" class="btn btn-primary" data-loading-text="正在提交...">确 定</button>
</div>
<script type="text/javascript">
	function city(str){
		$("#ccode1").val("");
		$("#ppcode1").val("");
		var id=str.split(";")[0];
		var obj=${obj!};
		var html='<option value="">--请选择--</option>';
		for(var i=0;i<obj.length;i++){
			if(obj[i].parent_id==id){
				html+='<option value="'+obj[i].id+';'+obj[i].ad_code+'">'+obj[i].name+'</option>';
			}
		}
		$("#ccode1").html(html);
	}
	function pp(str){
		$("#ppcode1").val("");
		var id=str.split(";")[0];
		var obj=${obj!};
		var html='<option value="">--请选择--</option>';
		for(var i=0;i<obj.length;i++){
			if(obj[i].parent_id==id){
				html+='<option value="'+obj[i].id+';'+obj[i].ad_code+'">'+obj[i].name+'</option>';
			}
		}
		$("#ppcode1").html(html);
	}
    function doIt() {
        if ( $("#ppcode1").val() == "") {
            Toast.error("场地名不可为空");
            $("#pcode1").focus();
            return false;
        }
        var ppcitys=document.getElementById('ppcode1').value
		var cityName=ppcitys.split(";")[1]; 
        /* var btn = $("#ok"); */
        var dialog = $("#dialogDetail");
       /*  btn.button("loading"); */
        $.post("${base}/platform/field/getTrain", {city: cityName}, function (data) {
            if (data.code == 0) {
                Toast.success("添加成功");
                dialog.modal("hide");
                datatable.ajax.reload();
            } else {
                Toast.error(data.msg);
            }
           /*  btn.button("reset"); */

        }, "json");
    }
</script>
